import Content from '../../preview/web';
import { createBehavior, createResource } from '@inbiz/core';
import { DnFC } from '@inbiz/react';
import locale from '../locale';
import React from 'react';
import { commonProps, defaultProps, propsSchema, defaultBizProps } from './schema';

const EformMemberSelect: DnFC<React.ComponentProps<typeof Content>> = Content;

EformMemberSelect.Behavior = createBehavior({
  name: 'EformMemberSelect',
  extends: ['Field'],
  selector: (node) => node?.props?.['x-component'] === 'EformMemberSelect',
  designerProps: {
    droppable: false,
    propsSchema,
  },
  designerLocales: locale,
});

EformMemberSelect.Resource = createResource({
  icon: 'MemberSelection',
  elements: [
    {
      componentName: 'Field',
      props: {
        ...commonProps,
        type: 'Array',
        'x-decorator': 'FormItem',
        'x-component': 'EformMemberSelect',
        'x-component-biz-props': defaultBizProps,
        'x-component-props': defaultProps,
      },
    },
  ],
});

export default EformMemberSelect;
